﻿using System;
using System.Linq;
using System.Collections.Generic;

using Web.Generics;

using BolaoDNA.DomainModel;
using BolaoDNA.Repositories;

namespace BolaoDNA.Services
{
	public class JogoService : GenericService<Jogo> {
		private readonly IJogoRepository repository;
		public JogoService(IJogoRepository repository, ILogger logger) : base(repository, logger)
		{
			this.repository = repository;
		}
        public IList<Jogo> TrazerProximosJogos(Competicao competicao, Int32 pageSize, Int32 pageIndex)
        {
            return this.repository.Select(new FilterParameters
            {
                FilterConditions = new[] {
                    new FilterCondition { Property= "Competicao.ID", Value = competicao.ID },
                    new FilterCondition { Property= "DataHora", Comparer=FilterCondition.ComparerType.gt, Value = DateTime.Now.AddHours(2) }
                }, 
                AllowPaging = true,
                PageSize = pageSize,
                PageIndex = pageIndex
            });
//.OrderBy(j => j.DataHora);
        }

	}
}
